package com.txts.road.app.message.controller;

import com.txts.road.app.message.model.dto.ContactDTO;
import com.txts.road.app.message.model.vo.ContactVO;
import com.txts.road.app.message.service.ContactService;
import com.txts.base.common.domain.ResponseDTO;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import jakarta.validation.Valid;

import java.util.List;


/**
 * 联系人前端控制层
 *
 * @author baoyr
 * @since 2025-07-17 15:01
 */
@Tag(name = "联系人接口")
@RestController
@RequestMapping("/api/v1/contact")
@RequiredArgsConstructor
public class ContactController {
    private final ContactService contactService;

    /**
     * 获取联系人列表
     */
    @Operation(summary = "获取联系人列表")
    @GetMapping("/contacts")
    public ResponseDTO<List<ContactVO>> getContacts() {
        return ResponseDTO.ok(contactService.getContacts());
    }


    /**
     * 添加联系人
     */
    @Operation(summary = "添加联系人")
    @PostMapping("/contact/add")
    public ResponseDTO<Boolean> addContact(@Valid @RequestBody ContactDTO addDTO) {
        return ResponseDTO.ok(contactService.addContact(addDTO));

    }

    @Operation(summary = "修改联系人")
    @PostMapping("/contact/update")
    public ResponseDTO<Boolean> updateContact(@Valid @RequestBody ContactDTO addDTO) {
        return ResponseDTO.ok(contactService.updateContact(addDTO));

    }


    /**
     * 删除联系人
     */
    @Operation(summary = "删除联系人")
    @DeleteMapping("/contact")
    public ResponseDTO<Boolean> deleteContact(@RequestBody List<Long> contactIds) {
        return ResponseDTO.ok(contactService.deleteContact(contactIds));
    }
}
